﻿Imports System.Globalization
Imports System.Threading
Imports System.ComponentModel

Imports System.Text
Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary

Imports System.Reflection

Imports System.Diagnostics
Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class frmMain

    'Private Function LoadForm(ByVal formClassName As String) As FrmBase
    '    Dim formInstance As FrmBase
    '    Dim formTypeClass As Type = Type.GetType("Itasoft.ACE.View." + formClassName, True)
    '    formInstance = CType(Activator.CreateInstance(formTypeClass), FrmBase)
    '    If formInstance.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedDialog Then
    '        formInstance.Owner = Me
    '    Else
    '        formInstance.MdiParent = Me
    '    End If
    '    formInstance.FormDebug = FrmDevDebug
    '    Return formInstance
    'End Function

    Private Sub LoadWellcome()
        Core.StatusMessage.Frm = Me
        Core.StatusMessage.Show("Bem vindo!")
    End Sub

    Private Sub LoadForm(ByVal Frm As FrmBase)
        Frm.Show(DockPanel1, WeifenLuo.WinFormsUI.Docking.DockState.Document)

        ' Sem DockPanel (Desativar também a herança no FrmBase)
        'Frm.MdiParent = Me
        'Frm.Show()
    End Sub

    Private Sub exitSystem()
        If Dialog.QuestionYesNo("Deseja realmente sair do sistema") = Windows.Forms.DialogResult.Yes Then
            Application.Exit()
        End If
    End Sub

    Private Sub Configuracao()
        Dim Frm As New FrmConfiguracao
        LoadForm(Frm)
    End Sub


    Private Sub ClienteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClienteToolStripMenuItem.Click
        Dim Frm As New FrmClienteCadastro
        LoadForm(Frm)
    End Sub

    Private Sub SairToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SairToolStripMenuItem.Click
        exitSystem()
    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        'Dim Frm As New FrmClienteCadastro
        'LoadForm(Frm)

        Dim Frm As New FrmProdutoCadastro
        LoadForm(Frm)

        'Dim Frm As New FrmDebug
        'Frm.Owner = Me
        'Frm.ShowDialog()
    End Sub

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadWellcome()
    End Sub

    Private Sub ProdutoToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProdutoToolStripMenuItem1.Click
        Dim Frm As New FrmProdutoCadastro
        LoadForm(Frm)
    End Sub

    Private Sub NotaFiscalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotaFiscalToolStripMenuItem.Click
        Dim Frm As New FrmNF
        LoadForm(Frm)
    End Sub

    Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
        Dim Frm As New FrmDebug

        Frm.ShowDialog()
    End Sub

    Private Sub SobreToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SobreToolStripMenuItem.Click
        Configuracao()
    End Sub

    Private Sub LocalToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LocalToolStripMenuItem.Click
        Dim Frm As New frmEstoqueLocalCadastro
        LoadForm(Frm)
    End Sub

    Private Sub EstoqueToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles EstoqueToolStripMenuItem1.Click
        Dim Frm As New FrmEstoque
        LoadForm(Frm)
    End Sub

    Private Sub EmpresaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EmpresaToolStripMenuItem.Click
        Dim Frm As New FrmEmpresa
        LoadForm(Frm)
    End Sub
End Class

